#include<iostream>
#include<algorithm>
typedef long long ll;
using namespace std;
const ll maxn=100010;
ll p[maxn],a[maxn],b[maxn],c[maxn],ans[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
    for(ll i=1;i<=m;++i)
        cin>>p[i];
    for(ll i=1;i<n;++i)
        cin>>a[i]>>b[i]>>c[i];
    for(ll i=1;i<m;++i)
    {
        if(p[i]>p[i+1])
            ans[p[i+1]]++,ans[p[i]]--;
        else ans[p[i]]++,ans[p[i+1]]--;
    }
    for(ll i=1;i<=n;++i)
        ans[i]+=ans[i-1];
    ll sum=0;
    for(ll i=1;i<n;++i)
        sum+=min(a[i]*ans[i],c[i]+b[i]*ans[i]);
    cout<<sum<<endl;
    return 0;
}
